package cn.com.zsw.gblog.modules.gblog.controller;

import cn.com.zsw.gblog.modules.common.service.CaptchaService;
import cn.com.zsw.gblog.vo.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * 验证码操作处理
 *
 * @author ruoyi
 */
@RestController
@Slf4j
public class CaptchaController {
    @Autowired
    CaptchaService captchaService;

    /**
     * 生成验证码
     */
    @GetMapping("/captchaImage")
    public R getCode() throws IOException {
//        Collection<? extends GrantedAuthority> authorities = SecurityContextHolder.getContext().getAuthentication().getAuthorities();
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return R.SUCCESS.data(captchaService.generateImageCaptcha());
    }
}
